package com.xinxin.leetcode.problem561;

import java.util.Arrays;

/**
 * @author ShiXinXin
 * @date 2020-01-29 23:01
 */
public class Solution {
    public int arrayPairSum(int[] nums) {
        int sum = 0;
        Arrays.sort(nums);
        for (int i = 0; i < nums.length; i += 2) {
            sum += nums[i];
        }
        return sum;
    }

    public static void main(String[] args) {
        int[] arr = {1, 4, 3, 2};
        System.out.println(new Solution().arrayPairSum(arr));
    }
}
